﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CreateDirectorate.ascx.cs"
    Inherits="Pantry.Web.Users.Controls.CreateDirectorate" %>
<%@ Register TagPrefix="CC" Namespace="SiteUtils" Assembly="CollectionPager" %>
<%@ Register TagPrefix="UC1" TagName="ListContact" Src="ListContact.ascx" %>
<%@ Register TagPrefix="UC2" TagName="ListPostcode" Src="ListPostcode.ascx" %>
<%@ Register TagPrefix="UC3" TagName="ListBusiness" Src="ListTypeOfBusiness.ascx" %>
<asp:UpdatePanel runat="server" ID="UpdatePanel">
    <Triggers>
        <asp:PostBackTrigger ControlID="ButtonInActive" />
        <asp:AsyncPostBackTrigger ControlID="CheckBoxCopyAddress" EventName="CheckedChanged" />
        <asp:AsyncPostBackTrigger ControlID="TextBoxPostcode" EventName="TextChanged" />
    </Triggers>
    <ContentTemplate>
        <%--<div id="detail_block" class="g_12">--%>
        <div class="widget_header">
            <h4 class="widget_header_title wwIcon i_16_icons">
                Directorate Details</h4>
            <div class="top-nav">
                <asp:Button ID="ButtonInactive" runat="server" Text="In-active" CssClass="buttontop"
                    OnClientClick="return confirm('Do you want to in-active this department ?')"
                    OnClick="ButtonInactiveClick" />
                <asp:Button ID="Button1" runat="server" Text="Save" CssClass="buttontop" OnClick="ButtonSaveClick"
                    OnClientClick="return validate();" />
                <asp:Button ID="Button2" runat="server" Text="Back" CssClass="buttontop" OnClick="ButtonBackClick" />
            </div>
        </div>
        <div id="input_form" class="widget_contents noPadding">
            <div id="left_column">
                <div id="line_1" class="grid_line">
                    <div class="block_label label">
                        Department Name: <span class="must">*</span>
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextBoxDepartmentName" runat="server" CssClass="simple_field" ToolTip="The Department Name is required!" />
                        <asp:HiddenField runat="server" ID="HiddenDirectorateName" />
                    </div>
                </div>
                <div id="line_2" class="grid_line">
                    <div class="block_label">
                        Department Short Description:
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextAreaShortDescriptionription" TextMode="MultiLine" runat="server" CssClass="textarea_custom" />
                    </div>
                </div>
                <div id="line_3" class="grid_line">
                    <div class="block_label">
                        Lead contact:
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextBoxLeadContactName" runat="server" ReadOnly="True" CssClass="simple_field manager_text_length"
                            Enabled="False" ToolTip="Lead Contact is required!" />
                        <asp:HiddenField ID="HiddenContactId" runat="server" />
                        <asp:Button runat="server" ID="ContactLookup" Text="Lookup" CssClass="buttonlookup lookupcontact simple_buttons" />
                    </div>
                </div>
                <div id="line_4" class="grid_line">
                    <div class="block_input">
                        <asp:CheckBox ID="CheckBoxCopyAddress" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBoxCopyAddressCheckedChanged" />
                        <span style="font-family: Droid Sans; font-size: 14px; color: #8F8F8F">Copy Address
                            from Organisation </span>
                    </div>
                </div>
                <div id="line_5" class="grid_line">
                    <div class="block_label">
                        Address Line 1: <span class="must">*</span>
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextBoxAddressLine1" runat="server" CssClass="simple_field" ToolTip="Address Line 1 is required!" />
                    </div>
                </div>
                <div id="line_6" class="grid_line">
                    <div class="block_label">
                        Address Line 2:
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextBoxAddressLine2" runat="server" CssClass="simple_field" />
                    </div>
                </div>
                <div id="line_7" class="grid_line">
                    <div class="block_label">
                        Address Line 3:
                    </div>
                    <div class="block_input">
                        <asp:TextBox ID="TextBoxAddressLine3" runat="server" CssClass="simple_field" />
                    </div>
                </div>
                <div id="line_15" class="grid_line">
                    <div class="block_label">
                        Postcode<span class="must">*</span>
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxPostcode" CssClass="simple_field manager_text_length"
                            Enabled="False" OnTextChanged="TextBoxPostcodeTextChanged" ToolTip="Postcode is required!"/>
                        <asp:Button runat="server" ID="PostcodeLookup" CssClass="buttonlookup lookupPostcode simple_buttons"
                            Text="Lookup" />
                    </div>
                </div>
                <div class="grid_line" id="line_16">
                    <div class="block_label">
                        Town/Village/ City
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxTown" CssClass="simple_field" />
                    </div>
                </div>
                <div id="line_17" class="grid_line">
                    <div class="block_label">
                        County
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxCounty" CssClass="simple_field" />
                    </div>
                </div>
                <div id="line_18" class="grid_line">
                    <div class="block_label">
                        Country
                    </div>
                    <div class="block_input">
                        <asp:DropDownList runat="server" ID="DropDownCountry" CssClass="selector">
                        </asp:DropDownList>
                    </div>
                </div>
            </div>
            <div id="right_column" class="column">
                <div id="line_8" class="grid_line">
                    <div class="block_label">
                        Type of Business <span class="must">*</span>
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxTypeOfBusiness" ReadOnly="True" CssClass="simple_field manager_text_length" ToolTip="Type Of Business is required!" />
                        <asp:HiddenField runat="server" ID="HiddenFieldTypeOfBusiness" />
                        <asp:Button runat="server" ID="BusinessLookup" Text="Lookup" CssClass="buttonlookup lookupBusiness simple_buttons" />
                    </div>
                </div>
                <div id="line_9" class="grid_line">
                    <div class="block_label">
                        SIC Code:
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxSicCode" CssClass="simple_field" Enabled="false" />
                    </div>
                </div>
                <div id="line_10" class="grid_line">
                    <div class="block_label">
                        BU/ Directorate Full Description
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextAreaFullDescriptionription" TextMode="MultiLine" CssClass="textarea_custom" />
                    </div>
                </div>
                <div id="line_11" class="grid_line">
                    <div class="block_label">
                        Phone number
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxPhoneNumber" CssClass="simple_field" ToolTip="Example: 111-111-1111"/>
                    </div>
                </div>
                <div id="line_12" class="grid_line">
                    <div class="block_label">
                        Fax:
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxFax" CssClass="simple_field" ToolTip="Example: 111-111-1111" />
                    </div>
                </div>
                <div id="line_13" class="grid_line">
                    <div class="block_label">
                        Email:
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxEmail" CssClass="simple_field" ToolTip="Example: abc@mail.com" />
                    </div>
                </div>
                <div id="line_14" class="grid_line">
                    <div class="block_label">
                        Web Address
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxWebAddress" CssClass="simple_field" ToolTip="Example: http://www.web.com" />
                    </div>
                </div>
                <div id="line_19" class="grid_line">
                    <div class="block_label">
                        Charity Number
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxCharityNumber" CssClass="simple_field" />
                    </div>
                </div>
                <div id="line_20" class="grid_line">
                    <div class="block_label">
                        Company Number
                    </div>
                    <div class="block_input">
                        <asp:TextBox runat="server" ID="TextBoxCompanyNumber" CssClass="simple_field" />
                    </div>
                </div>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
<div class="dialog DialogListContact" style="display: none" title="List Contact">
    <UC1:ListContact runat="server" ID="ListContact" />
</div>
<div class="dialog DialogListOfBusiness" style="display: none" title="ListTypeOfBusiness">
    <UC3:ListBusiness runat="server" ID="ListBusiness" />
</div>
<div class="dialog DialogListOfPostCode" style="display: none" title="List Postcode">
    <UC2:ListPostcode runat="server" ID="ListPostCode" />
</div>
<!--Ajax tookit-->

<script language="javascript" type="text/javascript">
    function validate() {
        if (document.getElementById("<%=TextBoxDepartmentName.ClientID%>").value == "") {
            showmessage('Please input Directorate name !', 'ERROR', '', 'false');
            document.getElementById("<%=TextBoxDepartmentName.ClientID%>").focus();
            return false;
        }
        if (document.getElementById("<%=TextAreaShortDescriptionription.ClientID%>").value == "") {
            showmessage('Please input short description !', 'ERROR', '', 'false');
            document.getElementById("<%=TextAreaShortDescriptionription.ClientID%>").focus();
            return false;
        }
        if (document.getElementById("<%=TextBoxLeadContactName.ClientID%>").value == "") {
            showmessage('Please select lead contact !', 'ERROR', '', 'false');
            document.getElementById("<%=TextBoxLeadContactName.ClientID%>").focus();
            return false;
        }
        if (document.getElementById("<%=TextBoxTypeOfBusiness.ClientID%>").value == "") {
            showmessage('Please select type of business !', 'ERROR', '', 'false');
            document.getElementById("<%=TextBoxTypeOfBusiness.ClientID%>").focus();
            return false;
        }
        if (document.getElementById("<%=TextBoxPhoneNumber.ClientID%>").value != "") {
            var phone = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
            var phoneid = document.getElementById("<%=TextBoxPhoneNumber.ClientID %>").value;
            var matchArray = phoneid.match(phone);
            if (matchArray == null) {
                showmessage('Phone number is invalid format ! Example: xxx-xxx-xxxx', 'ERROR', '', 'false');
                document.getElementById("<%=TextBoxPhoneNumber.ClientID %>").focus();
                return false;
            }
        }
        if (document.getElementById("<%=TextBoxFax.ClientID%>").value != "") {
            var phone = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
            var phoneid = document.getElementById("<%=TextBoxFax.ClientID %>").value;
            var matchArray = phoneid.match(phone);
            if (matchArray == null) {
                showmessage('Fax number is invalid format ! Example: xxx-xxx-xxxx', 'ERROR', '', 'false');
                document.getElementById("<%=TextBoxFax.ClientID %>").focus();
                return false;
            }
        }
        if (document.getElementById("<%=TextBoxEmail.ClientID %>").value != "") {
            var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
            var emailid = document.getElementById("<%=TextBoxEmail.ClientID %>").value;
            var matchArray = emailid.match(emailPat);
            if (matchArray == null) {
                showmessage('Email is invalid format !', 'ERROR', '', 'false');
                document.getElementById("<%=TextBoxEmail.ClientID %>").focus();
                return false;
            }
        }

        if (document.getElementById("<%=TextBoxWebAddress.ClientID %>").value == "") {
            showmessage('Please input web address !', 'ERROR', '', 'false');
            document.getElementById("<%=TextBoxWebAddress.ClientID %>").value = "http://"
            document.getElementById("<%=TextBoxWebAddress.ClientID %>").focus();
            return false;
        }
        var Url = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"
        var tempURL = document.getElementById("<%=TextBoxWebAddress.ClientID%>").value;
        var matchURL = tempURL.match(Url);
        if (matchURL == null) {
            showmessage('Web URL does not look valid !', 'ERROR', '', 'false');
            document.getElementById("<%=TextBoxWebAddress.ClientID %>").focus();
            return false;
        }
        return true;
    }
</script>

